using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Globalization;
using Rolodex.Model;
using Rolodex.Properties;

namespace Rolodex.Views
{
    public partial class MainView : Form
    {
        #region Properties
        public BindingSource Cards
        {
            get { return this._Cards; }
        }

        public Button buttonNew
        {
            get { return this._buttonNew; }
        }

        public Button buttonEdit
        {
            get { return this._buttonEdit; }
        }

        public Button buttonDelete
        {
            get { return this._buttonDelete; }
        }

        public ToolStripLabel labelCardCollectionPath
        {
            get { return this._labelCardCollectionPath; }
        }

        public Button buttonPrevious
        {
            get { return this._buttonPrevious; }
        }

        public ToolStripLabel labelRecordPosition
        {
            get { return this._labelRecordPosition; }
        }

        public ToolStripLabel labelSearchResultPosition
        {
            get { return this._labelSearchResultPosition; }
        }

        public Button buttonNext
        {
            get { return this._buttonNext; }
        }

        public LinkLabel linklabelEmailAddress
        {
            get { return this._linklabelEmailAddress; }
        }

        public TextBox textboxCriteria
        {
            get { return this._textboxCriteria; }
        }

        public Button buttonSearch
        {
            get { return this._buttonSearch; }
        }

        public Button buttonClear
        {
            get { return this._buttonClear; }
        }

        public ComboBox comboboxLetter
        {
            get { return this._comboboxLetter; }
        }

        public OpenFileDialog OpenFileDialog
        {
            get { return this._OpenFileDialog; }
        }

        public ToolStripMenuItem menuitemLink
        {
            get { return this._menuitemAbout; }
        }

        public ToolStripMenuItem menuitemOpen
        {
            get { return this._menuitemOpen; }
        }

        public ToolStripMenuItem menuitemRefresh
        {
            get { return this._menuitemRefresh; }
        }

        public ToolStripMenuItem menuitemSave
        {
            get { return this._menuitemSave; }
        }

        public ToolStripMenuItem menuitemExit
        {
            get { return this._menuitemExit; }
        }

        public Timer timerRefresh
        {
            get { return this._timerRefresh; }
        }

        public NotifyIcon NotifyIcon
        {
            get { return this._NotifyIcon; }
        }
        #endregion

        #region Methods
        public MainView()
        {
            InitializeComponent();

            this._menuitemAbout.Text = String.Format(
                CultureInfo.CurrentCulture,
                "ne0ge0.com // {0}",
                DateTime.Now.Year);

            this._Card.DataSource = new Card();
        }

        #region Event Handlers
        private void _textboxCriteria_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.KeyCode.Equals(Keys.Enter))
            {
                this._buttonSearch.PerformClick();
                this._textboxCriteria.Clear();
            }
        }
        
        private void _textboxCriteria_Enter(object sender, EventArgs e)
        {
            if (this._textboxCriteria.Text.Equals("Type here to search..."))
            {
                this._textboxCriteria.Clear();
            }
        }

        private void _textboxCriteria_Leave(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(this._textboxCriteria.Text))
            {
                this._textboxCriteria.Text = "Type here to search...";
            }
        }
        #endregion

        #region Helpers
        public void EnableView()
        {
            this._textboxCriteria.Enabled =
                this._comboboxLetter.Enabled =
                this._buttonEdit.Enabled =
                this._buttonDelete.Enabled =
                    true;
        }

        public void DisableView()
        {
            this._textboxCriteria.Enabled =
                this._comboboxLetter.Enabled =
                this._buttonEdit.Enabled =
                this._buttonDelete.Enabled =
                    false;

            this._labelRecordPosition.Text =
                String.Empty;
        }
        #endregion
        #endregion
    }
}